import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

public class EJBSessionBeanClient {
	public static void main(String[] args) throws NamingException {
		//It will add initial context where we are setting up properties to locate session bean
		Context mycontext = EJBSessionBeanClient.getIntialContext();
		//Here we are catching up our session bean defined in another project
		EJBSessionBeanRemote ejbClientSessionBean = (EJBSessionBeanRemote) mycontext.lookup("EJBSessionBean/remote");
		ejbClientSessionBean.ejbSessionBeanMethod();
	}
	
	//Here we are defining properties to get initial context by giving application sever name and url where
	//we have deployed our session bean 
	public static Context getIntialContext() throws NamingException{
		Properties myproperties = new Properties();
		myproperties.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory");
		myproperties.setProperty("java.naming.factory.url.pkgs","org.jboss.naming");
		myproperties.setProperty("java.naming.provider.url","127.0.0.1:1099");
		return new InitialContext(myproperties);			
	}
}